﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.App.Apilication.Common.Deep;
using Traceability.Domain;
using Traceability.ErrorCode;

namespace Traceability.App.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DeepController : ControllerBase
    {
        private readonly IMediator mediator;

        public DeepController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        ///新增深加工信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> CreateDeepHandle(CreateDeepCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 修改深加工信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdateDeepHandle(UpdateDeepCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 根据生产批次查询深加工信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<DeepProcessing>>> GetDeepHandle([FromQuery]GetDeepCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 新增深加工的企业信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> CreateDeepEnterHandle(CreateDeepEnterCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 修改深加工的企业信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public Task<ApiResult<int>> UpdateDeepEnterHandle(UpdateDeepEnterCommon request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 根据生产批次显示深加工的企业信息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<DeepEnterprisess>>> GetDeepEnterHandle([FromQuery]GetDeepEnterCommon request)
        {
            return mediator.Send(request);
        }

        }
}
